<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/10/29
 * Time: 0:12
 */

namespace app\MAPP\shop\ctl;


use function core\backto;
use function core\backto2;
use core\lib\BaseControlerDB;
use app\MAPP\shop\mode\lists\func as lis;
use function core\alert;
use function core\p;
use function core\pplain;
use Extentions\template\Template;

class carmc extends BaseControlerDB
{
    var $mode;
    function __USERFUNC()
    {
        $this->mode = new lis();
        if (!($this->msg->ip == "::1" || $this->msg->ip=="127.0.0.1")){
            backto2("/run/index/index");
        }
    }

    function index(){
        pplain("index");
    }

    function car($id){
        $this->mode->car($id);
        alert("ok");
        backto2($this->msg->referer);
    }

    function dcar($id){
        $this->mode->deccar($id);
        p("ok");
        backto2($this->msg->referer);
    }

    function mcar(){
        $temp = $this->mode->mcar();
        $tpl = Template::Newinstance();
        $tpl->displayN("bar.php",__DIR__);
        $tpl->assign("data",date("Y M D h:m:s"));
        $tpl->assign("shop",$temp[1]);
        $tpl->assign("sum",$temp[0]);
        $tpl->displayFd("car.php",__DIR__);

    }

    function delcar(){
        $this->mode->delcar();
        alert("shoping car is empty!go shoping quick!");
        alert("ok");
        backto2($this->msg->referer);
    }

    function delc($id){
        $this->mode->delocar($id);
        alert("ok");
        backto2($this->msg->referer);
    }

    function savecar(){
        $this->mode->savecar();
        alert("ok");
        backto2($this->msg->referer);
    }

}